﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace SqlServerDataExporter
{
    public class ReportProgress : IReportProgress
    {

        private BackgroundWorker _worker;

        private int _count;

        public ReportProgress(BackgroundWorker worker)
        {
            this._worker = worker;
        }

        public void DoReportNextItem()
        {
            _count++;
            if (_count % 100 == 0)
            {
                this._worker.ReportProgress(_count);
            }
        }

        public void ReportLastItem()
        {
            this._worker.ReportProgress(_count);
        }

        public bool DoCancel
        {
            get
            {
                return this._worker.CancellationPending;               
            }
        }
    }
}
